home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre1.z / postgre1 / demo / DEMO-README < prev    next >
Encoding:
Text File  |  1992-08-27  |  3.8 KB  |  101 lines

  1. Notes on the Demo Scripts:
  2.  
  3. To run the demo, run the Postmaster if you are not running it already, and
  4. create a demo database using the createdb (unix) command.  After this,
  5. cd into ~postgres/demo and run the Monitor.  The '*' indicates the Monitor
  6. prompt.
  7.  
  8.  
  9. Note: An alternative that avoids all of this typing is to run the wholedemo.sh
  10. script.  It creates a database demo and runs each of the demo queries
  11. automatically.  The queries run are echoed so you can see exactly what the
  12. demo does by simply examining the output that the script produces.
  13.  
  14. 1.  Populate the demo database.  You do this by doing
  15.  
  16. * \i set-up-1.pq
  17. <you will see lots of stuff>
  18. (On certain machines, running this may take awhile - be patient)
  19.  
  20. After this, run scripts 1 through 22 in the following manner
  21.  
  22. * \i script-nn
  23.  
  24. where nn is from 1 to 25.
  25.  
  26. Script 1 shows the initial state of the "city" and "emp" tables.
  27.  
  28. Script 2 runs a simple query using a join. 
  29.  
  30. Script 3 shows the Postgres feature of user-defined functions at work.  The
  31. "boxarea" function returns the area of the city by using its "location"
  32. parameter.  The source for this function is in ~postgres/demo/boxarea.c, and
  33. this function is defined in set-up-1.pq.
  34.  
  35. Script 4 shows an inheritable or tuple function at work.  The source for
  36. "overpaid" is in ~postgres/demo/overpaid.c.  Writing an inheritable function
  37. is described in the tutorial "Writing a Function of a Tuple".
  38.  
  39. Script 5 shows an array being used in a query.  In this case, the array is the
  40. fixed-length array "budget", which has four elements.  Postgres supports both
  41. fixed-length and variable-length arrays of fixed-size elements.  Postgres
  42. arrays are discussed in the tutorial "Defining an Array Type".
  43.  
  44. Script 6 shows an operator working on the "location" field.  Users can define
  45. unary or binary operators which operate on any Postgres type.
  46.  
  47. Script 7 shows an operator being defined.  The C function pt_in_circle()
  48. evaluates the arguments of the operator and returns the result - the source
  49. to this function is in ~postgres/demo/circle.c.  This C function and the
  50. circle type (as well as its in/out functions) are defined by queries in
  51. set-up-1.pq.  User defined types, operators, and functions are described in
  52. detail in the tutorial "Defining User Defined Types, Operators, and Functions".
  53.  
  54. Script 8 shows the operator in Script 7 being used in a query.
  55.  
  56. Script 9, 10, and 11 show Postgres time-based queries at work.  The query in
  57. script 9 shows Sam's current salary.
  58.  
  59. Script 10 gives Sam a raise.
  60.  
  61. Script 11 shows Sam's salary history, using the special Postgres time
  62. attributes "tmin", and "tmax".
  63.  
  64. Script 12 shows a join of the student and emp tables.
  65.  
  66. Script 13 shows a similar appearing query, but this time inheritance is used
  67. by the "*" notation.  
  68.  
  69. Script 14 shows the current state of the emp table.
  70.  
  71. Script 15 defines a tuple level rule.  This rule forces Bill's salary to be
  72. equal to Sharon's salary.
  73.  
  74. Script 16 defines another tuple level rule.  This rule forces Sam's salary
  75. to be twice Bill's salary.
  76.  
  77. Script 17 gives Sharon a raise, causing both rules to fire.
  78.  
  79. Script 18 shows that both rules did fire by showing the new state of the emp
  80. table.
  81.  
  82. Script 19 deletes these rules.
  83.  
  84. Script 20 defines a backward-chaining tuple rule.  This rule retrieves twice
  85. Bill's salary whenever an attempt is made to fetch Sam's salary.
  86.  
  87. Script 21 defines another backward-chaining tuple rule.  This rule retrieves
  88. thrice Sharon's salary whenever a fetch is made to Bill's salary.
  89.  
  90. Script 22 shows these rules in action, by doing a retrieve on the emp table.
  91.  
  92. Script 23 demonstrates the average aggregate on the emp table.
  93.  
  94. Script 24 demonstrates how to create an aggregate named "bletch"
  95.  
  96. Script 25 simple removes the aggregate named "bletch"
  97.  
  98. The Postgres rule system is described in the paper "On Rules, Caching,
  99. Procedures, and Views", which is included in this distribution in the
  100. ./doc/papers directory.
  101.